<template>
	<div class="school">
		<h2>我是School组件</h2>
		<h3>学校名称：{{name}}</h3>
		<h3>学校地址：{{address}}</h3>
		<button @click="sendName">传递学校名给App</button>
		<button @click="jieBang">解绑我身上的haha事件</button>
		<button @click="xiaohui">销毁School的vc</button>
	</div>
</template>

<script>
	export default {
		name:'School',
		data() {
			return {
				name:'尚硅谷',
				address:'宏福科技园'
			}
		},
		methods:{
			sendName(){
				this.$emit('haha',this.name) //触发School组件实例的haha事件
			},
			jieBang(){
				this.$off('haha') //传入哪个事件名，就解绑哪个事件，若不传，就全部解绑
			},
			xiaohui(){
				this.$destroy()
			}
		},
	}
</script>

<style>
	.school{
		background-color: orange;
		padding: 10px;
	}
</style>